import { createRouter, createWebHashHistory } from "vue-router";
/* 
layoutA:带侧边栏
layoutB:无侧边栏
*/
const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/Login/index.vue"),
  },
  {
    path: "/",
    component: () => import("@/layout/index.vue"),
    redirect: "/home",
    children: [
      // 首页
      {
        path: "/home",
        name: "Home",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Home/index.vue"),
        redirect: "/home/homeCommunity",
        children: [
          {
            path: "homeCommunity",
            name: "HomeCommunity",
            component: () => import("@/views/Home/compents/Main/homeCommunity/index.vue"),
          },
          {
            path: "homeJob",
            name: "HomeJob",
            component: () => import("@/views/Home/compents/Main/homeJob/index.vue"),
          },
          {
            path: "homeNotice",
            name: "HomeNotice",
            component: () => import("@/views/Home/compents/Main/homeNotice/index.vue"),
          },
        ],
      },
      // 设备管理页（使用layoutB）
      {
        path: "/equipment",
        name: "Equipment",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Equipment/index.vue"),
        redirect: "/equipment/equipmentManage",
        children: [
          {
            path: "equipmentManage",
            name: "EquipmentManage",
            component: () =>
              import(
                "@/views/Equipment/compents/Main/equipmentManage/index.vue"
              ),
          },
        ],
      },
      // 角色(权限)管理页（使用layoutB）
      {
        path: "/role",
        name: "Role",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Role/index.vue"),
        redirect: "/role/roleManage",
        children: [
          {
            path: "roleManage",
            name: "RoleManage",
            component: () =>
              import("@/views/Role/compents/Main/roleManage/index.vue"),
          },
          {
            path: "routeManage",
            name: "RouteManage",
            component: () =>
              import("@/views/Role/compents/Main/routeManage/index.vue"),
          },
          {
            path: "apiManage",
            name: "ApiManage",
            component: () =>
              import("@/views/Role/compents/Main/apiManage/index.vue"),
          },
          {
            path: "rightManage",
            name: "RightManage",
            component: () =>
              import("@/views/Role/compents/Main/rightManage/index.vue"),
          },
        ],
      },
      // 人员管理页（使用layoutB）
      {
        path: "/man",
        name: "Man",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Man/index.vue"),
        redirect: "/man/userManage",
        children: [
          {
            path: "userManage",
            name: "UserManage",
            component: () =>
              import("@/views/Man/compents/Main/userManage/index.vue"),
          },
          {
            path: "residentManage",
            name: "ResidentManage",
            component: () =>
              import("@/views/Man/compents/Main/residentManage/index.vue"),
          },
          {
            path: "inspectorManage",
            name: "InspectorManage",
            component: () =>
              import("@/views/Man/compents/Main/inspectorManage/index.vue"),
          },
        ],
      },
      // 任务管理页（使用layoutB）
      {
        path: "/task",
        name: "Task",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Task/index.vue"),
        redirect: "/task/taskManage",
        children: [
          {
            path: "taskManage",
            name: "TaskManage",
            component: () =>
              import("@/views/Task/compents/Main/taskManage/index.vue"),
          },
          {
            path: "taskJob",
            name: "TaskJob",
            component: () =>
              import("@/views/Task/compents/Main/taskJob/index.vue"),
          },
          {
            path: "taskNotice",
            name: "TaskNotice",
            component: () =>
              import("@/views/Task/compents/Main/taskNotice/index.vue"),
          },
        ],
      },
      // 应急事件模块（使用layoutB）
      {
        path: "/event",
        name: "Event",
        meta: { layout: "layoutB" },
        component: () => import("@/views/QuickEvent/index.vue"),
        redirect: "/event/eventManage",
        children: [
          {
            path: "eventManage",
            name: "EventManage",
            component: () =>
              import("@/views/QuickEvent/compents/Main/eventManage/index.vue"),
          },
          {
            path: "maxEvent",
            name: "MaxEvent",
            component: () =>
              import("@/views/QuickEvent/compents/Main/eventMaxType/index.vue"),
          },
          {
            path: "eventReport",
            name: "EventReport",
            component: () =>
              import("@/views/QuickEvent/compents/Main/eventReport/index.vue"),
          },
          {
            path: "eventRecord",
            name: "EventRecord",
            component: () =>
              import("@/views/QuickEvent/compents/Main/eventRecord/index.vue"),
          },
        ],
      },
      // 应急预案管理页（使用layoutB）
      {
        path: "/plan",
        name: "Plan",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Plan/index.vue"),
        redirect: "/plan/planList",
        children: [
          {
            path: "planList",
            name: "PlanList",
            component: () =>
              import("@/views/Plan/compents/Main/planList/index.vue"),
          },
          {
            path: "planDrill",
            name: "PlanDrill",
            component: () =>
              import("@/views/Plan/compents/Main/planDrill/index.vue"),
          },
          {
            path: "planTeam",
            name: "PlanTeam",
            component: () =>
              import("@/views/Plan/compents/Main/planTeam/index.vue"),
          },
        ],
      },
      // 404页面（可以指定特定布局或使用默认）
      {
        path: "/404",
        meta: { layout: "layoutB" }, // 示例中使用layoutA
        component: () => import("@/views/error/error.vue"),
      },
      // 个人信息页
      {
        path: "/oneself",
        name: "Oneself",
        meta: { layout: "layoutB" },
        component: () => import("@/views/Oneself/index.vue"),
      },
    ],
  },
  {
    path: "/:pathMatch(.*)*",
    name: "Any",
    redirect: "/404",
  },
];
const router = createRouter({
  history: createWebHashHistory(),
  routes,
});
export default router;
